package com.lbs.jiepiaisi.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 *
 * 时间：2017/9/5 15:00
 * 作用：字符串工具类
 */

public class StringUtil {

    /**
     *字符串的日期格式的计算
     * 计算两个字符串日期之间的天数
     */
    public static int daysBetween(String smdate,String bdate) {

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        long between_days = 0,time1,time2;
        try {
            Calendar cal = Calendar.getInstance();
            cal.setTime(sdf.parse(smdate));
            time1 = cal.getTimeInMillis();
            cal.setTime(sdf.parse(bdate));
            time2 = cal.getTimeInMillis();
            between_days = (time2 - time1) / (1000*3600*24);
        } catch (Exception e){

        }

        return (int)between_days;
    }
    /**
     * 截取指定字符串之前的值
     */

    public static String Intercept(String str,String or){

        String value= str.substring(0, str.indexOf(or));

        return value;
    }
}


